var setZeroes = function(matrix) {
    for (let i = 0; i < matrix.length; i++) {
        let hasFlag = false
        for (let j = 0; j < matrix[0].length; j++) {
            if (matrix[i][j] === 0) {
                hasFlag = true
                matrix[i][j] = '-1'
            }
        }
        if (hasFlag) {
            for (let j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j] !== '-1') {
                    matrix[i][j] = 0
                }
            }
        }
        hasFlag = false
    }
    for (let i = 0; i < matrix[0].length; i++) {
        let hasFlag = false
        for (let j = 0; j < matrix.length; j++) {
            if (matrix[j][i] === '-1') {
                hasFlag = true
                break;
            }
        }
        if (hasFlag) {
            for (let j = 0; j < matrix.length; j++) {
                matrix[j][i] = 0
            }
        }
        hasFlag = false
    }
    return matrix
};
console.log(setZeroes([
    [0, 1, 2, 0],
    [3, 4, 5, 2],
    [1, 3, 1, 5]
]))